#if !defined(WEBBY_LOGGING_HXX)
#define WEBBY_LOGGING_HXX

#include <boost/shared_ptr.hpp>

#include <string>
#include <vector>
#include <sstream>

#define WEBBY_LOG(level,msg) { if (Logging::instance().logLevel() >= ((unsigned int)level)) { std::stringstream _s; _s << msg; Logging::instance().addLogMessage(level,Logging::instance().getCurrentTime(), _s.str(),__PRETTY_FUNCTION__,__LINE__); } }

namespace webby
{

	class LogListener;
	typedef boost::shared_ptr< LogListener > LogListenerPtr;

	class Logging
	{
	public:
		static Logging &instance();

		enum LogLevel
		{
			DISABLED = 0,
			CRITICAL = 1,
			WARNING = 2,
			INFORMATIONAL = 3,
			DEBUG = 4,
			ALL
		};

		unsigned int logLevel() const { return mCurrentLevel; }

		void addLogMessage( LogLevel level, double curTime, const std::string &logMessage, const std::string &function, unsigned int lineNumber );
		void setLogLevel( LogLevel level ) { mCurrentLevel = level; }

		void addLogListener( LogListenerPtr listener );
		double getCurrentTime() const;
	private:
		Logging();
		static Logging *mInstance;
		LogLevel mCurrentLevel;

		std::vector< LogListenerPtr > mLogListeners;

		double mStartTime;
	};

}

#endif
